<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        
    </style>
</head>

<body>

    <table border="1" align="center">
        <tr>
            <td>账户:</td>
            <td>
                <input type="text" id="Username" />
            </td>
            <td id="td_1" style="width: 200px;" ></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td>
                <input type="text" id="password_1"   />
            </td>
            <td id="td_2" style="width: 200px;" ></td>
            </td>
        </tr>
        
        <tr>
            <td colspan="3" align="center">
                <input type="button" id="submit" value="提交" />
            </td>
        </tr>
    </table>
    <script type="text/javascript">

        
        function op_1() {
            var op = /^[a-zA-Z]{6,}$/
            var Username = document.getElementById("Username").value
            if (op.test(Username)) {
                document.getElementById("td_1").innerHTML = "用户名格式正确"
                return true
            } else {
                document.getElementById("td_1").innerHTML = "错误,长度最少6位,字母组成"
                return false
            }
        }
        document.querySelector("input:nth-child(1)").onblur = op_1

        function op_2() {
            var op = /^\d{5,7}$/
            var password_1 = document.getElementById("password_1").value
            if (op.test(password_1)) {
                document.getElementById("td_2").innerHTML = "密码输入正确"
                return true
            } else {
                document.getElementById("td_2").innerHTML = "错误,长度5-7,数字组成"
                return false
            }
        }
        document.querySelector("tr:nth-child(2) input").onblur = op_2

        document.getElementById("submit").onclick = function () {
            let is1 = op_1();
            let is2 = op_2();
            if (is1&&is2) {
                alert("登陆成功")
            } else {
                alert("校验失败,不需登录")
            }
        }
    </script>

</body>

</html>